package com.egg.ylt.adapter.record;

import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.egg.ylt.R;
import com.egg.ylt.Utils.Constants;
import com.egg.ylt.pojo.BabyDynamicMsgEntity;
import com.egg.ylt.presenter.impl.RecordPresenter;
import com.yonyou.framework.library.adapter.rv.ItemViewDelegate;
import com.yonyou.framework.library.adapter.rv.ViewHolder;

/**
 * Created By Dlx
 * on 2019/1/19
 */
public class RecordSinglePicViewType implements ItemViewDelegate<BabyDynamicMsgEntity.ListBean> {
    private RecordPresenter mPresenter;

    public RecordSinglePicViewType(RecordPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.item_record_singlepic;
    }

    @Override
    public boolean isForViewType(BabyDynamicMsgEntity.ListBean item, int position) {
        if ("2".equals(item.getRecordType())) {
            return true;
        }
        return false;
    }

    @Override
    public void convert(ViewHolder holder, final BabyDynamicMsgEntity.ListBean listBean, final int position) {
        holder.setText(R.id.item_record_singlepic_relationship_tv, listBean.getRelationName());
        holder.setText(R.id.item_record_singlepic_date_tv, listBean.getTime());
        holder.setText(R.id.record_date_textview, listBean.getDate());
        holder.setText(R.id.record_date_days_textview, listBean.getWeek());
        Glide.with(mPresenter.getContext()).load(listBean.getImageUrl()).into((ImageView) holder.getView(R.id.item_record_singlepic_bigpic_iv));
        holder.setOnClickListener(R.id.item_record_singlepic_deleteiv, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPresenter.deleteBabyDynamicMsg(listBean.getId(), 0, position);
            }
        });
        holder.setOnClickListener(R.id.item_record_singlepic_bigpic_iv, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mPresenter.jumpToBigPic(listBean.getImageUrl());
            }
        });
    }
}
